package cn.wolfcode.shop.mq;

import cn.wolfcode.shop.web.controller.SecKillController;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.TextMessage;

/**
 * Created by wolfcode-lanxw
 */
@Component
public class TopicReceiver {
    @JmsListener(destination = MQConfig.SECKILL_OVER_SIGN_DESTINATION)
    public void receiveCancelSeckillOverMsg(Message message) throws JMSException {
        if(message instanceof TextMessage){
            TextMessage textMessage = (TextMessage) message;
            Long goodId = Long.valueOf(textMessage.getText());
            SecKillController.localOverMap.put(goodId,false);
        }
    }
}
